<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    
    <title>My JSP 'Register.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  <%@ page import="domain.*" %>
  <%
  	request.setCharacterEncoding("utf-8");
  	String name=(String)session.getAttribute("userId");
  %>
  <link rel="stylesheet" type="text/css" href="lucar-css/head-css.css" />
  <link rel="stylesheet" type="text/css" href="lucar-css/Borrow-css.css" />
  <body>
  	<div id="head">
    	<div id="h-logo">
        	<img src="lucar-image/logo.png" class="hl">
        </div>
        <div id="h-right">
        	<span id="hr-useCar" class="hr-span" onmouseover="headimg(1);" onMouseOut="headimg(2);">
            	<img id="uCOut" src="lucar-image/useCar-Out.png" class="hr-image" style="display:block">
            	<img id="uCOn" src="lucar-image/useCar-On.png" class="hr-image" style="display:none">
            </span>
            <span id="hr-aboutUs" class="hr-span" onmouseover="headimg(3);" onMouseOut="headimg(4);">
            	<img id="aUOut" src="lucar-image/aboutUs-Out.png" class="hr-image" style="display:block">
            	<img id="aUOn" src="lucar-image/aboutUs-On.png" class="hr-image" style="display:none">
            </span>
           
            <span id="user" class="button"   onMouseOver="headbutton(3);" onMouseOut="headbutton(4);" onclick="window.location.href='ASsuccess.jsp'">
            	<b class="hr-text" id="userId"><%=name %></b>
  			</span>
  			
  			<a href="index.jsp" id="exit"><span class="button" onMouseOver="headbutton(3);" onMouseOut="headbutton(4);">
  				<b class="hr-text">退出</b>
  			</span></a>
        </div>
    </div>
	<div id="Borrow-body">
    	<img src="lucar-image/Borrow-image/Mine.png" id="PC" onclick="window.location.href='ASsuccess.jsp'"/>
		<img src="lucar-image/Borrow-image/Borrow.png" id="Borrow"/>
        <img src="lucar-image/Borrow-image/Dingdan.png" id="Order" onclick="window.location.href='myOrders.jsp'"/>
        <img src="lucar-image/Borrow-image/Baoxiu.png" id="Repair" onclick="window.location.href='CarRepair.jsp'" />
        <img src="lucar-image/Borrow-image/Message.png" id="Guestbook" />
        <img src="lucar-image/Borrow-image/Password.png" id="Password" />
	</div>
	<span id="error" style=" color: red ;font-size: 14px;display:none;" >${message}</span><br/>
      <br>
  </body>
<script src="lucar-script/head-script.js"></script>
<script src="lucar-script/borrow-script.js"></script>
<script src="lucar-script/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
window.onload = function(){
	function box(){
		var oBox = document.getElementById("Borrow-body");
		var L1 = oBox.offsetWidth;
		var Left = (document.documentElement.clientWidth-L1)/2;
		oBox.style.left = Left+'px';
	}
	box();
	window.onresize = function(){
        box();
    }
  	var message=$("#error").text();
  	if(message == "你在用车"){
  		alert(message);
  		location.href="returnCar.jsp";
  	}
}
$(document).ready(function(){
  	$("#Borrow").click(function(){
  		var userId=$("#userId").text();
  		$.ajax({
  			type:"get",
  			url:'<%=basePath%>selectPayOrders.action',
  			data:"userId="+userId,
  			dataType:"json",
  			success:function(orders){
  				alert("您还有未支付的订单，不能租车！");
  				window.location.href="payOrders.jsp";
  			},
  			error:function(orders){
  				$.ajax({
		  			type:"get",
		  			url:'<%=basePath%>selectOrders.action',
		  			data:"userId="+userId,
		  			dataType:"json",
		  			success:function(orders){
		  				alert("您还未还车，不能租车！");
		  				window.location.href="returnCar.jsp";
		  			},
		  			error:function(orders){
		  				window.location.href="selectCar.jsp";
		  			},
		  		});
  			},
  		});
  	});
})
</script>
</html>